# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libbsd
pkgver=0.12.2
pkgrel=0
pkgdesc="commonly-used BSD functions not implemented by all libcs"
url="https://libbsd.freedesktop.org/"
arch="all"
license="BSD-3-Clause"
depends="musl"
depends_dev="bsd-compat-headers linux-headers libmd-dev libbsd=$pkgver-r$pkgrel" # libbsd.so is a GNU ld script and not symlink
makedepends_build="autoconf automake libtool"
makedepends_host="$depends_dev"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="https://libbsd.freedesktop.org/releases/libbsd-$pkgver.tar.xz"

# secfixes:
#   0.10.0-r0:
#     - CVE-2019-20367

prepare() {
	default_prepare

	./autogen
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

dev() {
	default_dev
	amove usr/lib/libbsd.so
}

sha512sums="
ce43e4f0486d5f00d4a8119ee863eaaa2f968cae4aa3d622976bb31ad601dfc565afacef7ebade5eba33fff1c329b5296c6387c008d1e1805d878431038f8b21  libbsd-0.12.2.tar.xz
"
